package com.rainman.simpleredis.demo.controller;

import com.rainman.simpleredis.core.SimpleRedis;
import com.rainman.simpleredis.core.delay_work.SimpleDelayWorkMsgBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;


/**
 * 测试延迟任务
 *
 */
@RestController
@RequestMapping("/delay")
public class DemoDelayWorkController {

    @Autowired
    SimpleRedis simpleRedis;

    @RequestMapping("/add")
    public String add(Long tigTime ){

        SimpleDelayWorkMsgBean simpleDelayWorkMsgBean = simpleRedis.addDelayWork("100", "1000"
                , "应触发时间" + new Date(System.currentTimeMillis() + tigTime)
                , System.currentTimeMillis() + tigTime);

        return simpleDelayWorkMsgBean.toString();
    }



}
